import 'package:flutter/material.dart';
import 'package:flutterhouse/pages/Home/components/nav_col.dart';

class HomeNav extends StatefulWidget {
  const HomeNav({super.key});

  @override
  State<HomeNav> createState() => _HomeNavState();
}

class _HomeNavState extends State<HomeNav> {
  //数据
  final List<Map> _navList = [
    {
      "label": "我的房屋",
      "name": 'house',
      "icon": "assets/images/house_profile_icon@2x.png"
    },
    {
      "label": "我的报修",
      "name": 'repair',
      "icon": "assets/images/repair_nav_icon@2x.png"
    },
    {
      "label": "访客登记",
      "name": 'visitor',
      "icon": "assets/images/visitor_nav_icon@2x.png"
    },
  ];
// list数组
  List<Widget> _getNavList() {
    return _navList.map((item) {
      return NavCol(
          icon: item['icon'],
          title: item['label'],
          onNavClick: () {
            if (item['name'] == 'house') {
              Navigator.pushNamed(context, '/house_list');
            }
          });
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.all(10),
      padding: const EdgeInsets.only(top: 10, bottom: 10),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(10), color: Colors.white),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: _getNavList(),
      ),
    );
  }
}
